/**************************************************************************************
 *  Copyright (c)  2010  Leszek Karcz.
 *  Permission is granted to copy, distribute and/or modify this document
 *  under the terms of the GNU Free Documentation License, Version 1.3
 *  or any later version published by the Free Software Foundation;
 *  with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
 *  A copy of the license is included in the section entitled "GNU
 *  Free Documentation License". 
 **************************************************************************************/
package data;

/**************************************************************************************
 * Author(s): Leszek Karcz
 * This class is a structure for housing and accessing tiles and path-finding
 **************************************************************************************/
public class VisibilityMap extends HexMap
{
	private ViewTile[][] viewTiles;
	
	/**************************************************************************************
	 * Author(s): Leszek Karcz
	 * Map constructor
	 **************************************************************************************/
	public VisibilityMap(int width, int height)
	{
		this.setWidth(width);
		this.setHeight(height);
		
		this.viewTiles = new ViewTile[height][width];
		for(int i=0; i<height; i++)
		{
			for(int j=0; j<width; j++)
			{
				this.viewTiles[i][j]=new ViewTile();
			}
		}		
	}
	
	/**************************************************************************************
	 * Author(s): Leszek Karcz
	 * Returns ViewTile at [x,y] coordinates
	 **************************************************************************************/
	public ViewTile getViewTile(int x, int y)
	{
		return this.viewTiles[y][x];
	}	
	
	/**************************************************************************************
	 * Author(s): Leszek Karcz
	 * returns image of the top item at [x,y] coordinates
	 **************************************************************************************/
	public String getTopItemDataAt(int x, int y)
	{
		return this.viewTiles[y][x].getTopItemData();
	}
	
	/**************************************************************************************
	 * Author(s): Leszek Karcz
	 * Returns image file for last seen structure at [x,y] coordinates
	 **************************************************************************************/
	public String[] getStructureDataAt(int x, int y)
	{
		return this.viewTiles[y][x].getStructureData();
	}
	
	/**************************************************************************************
	 * Author(s): Leszek Karcz
	 * Returns visibility status for a tile at [x,y] coordinates
	 **************************************************************************************/
	public boolean[] getVisibilityStatusAt(int x, int y, int tick)
	{
		return this.viewTiles[y][x].getVisibilityStatus(tick);
	}
	
	/**************************************************************************************
	 * Author(s): Leszek Karcz
	 * Discovers a tile at [x,y] coordinates, and updates it's "last viewed" status and data
	 **************************************************************************************/
	public void refreshTile(int x, int y, int tick, String structure, int structureOwnerID, int structureHealthPercentage, String item, String[] lastSeenResourceImages, String[] lastSeenResources, boolean prospectMode)
	{
		this.viewTiles[y][x].refreshTile(tick, structure, structureOwnerID , structureHealthPercentage, item, lastSeenResourceImages, lastSeenResources, prospectMode);
	}
	
	/**************************************************************************************
	 * Author(s): Leszek Karcz
	 * Returns last seen resource images
	 **************************************************************************************/
	public String[] getResourceImagesAt(int x, int y)
	{
		return this.viewTiles[y][x].getResourceImages();
	}
	
	/**************************************************************************************
	 * Author(s): Leszek Karcz
	 * Returns last seen resource amounts
	 **************************************************************************************/
	public String[] getResourceDataAt(int x, int y)
	{
		return this.viewTiles[y][x].getResourceData();
	}
}
